package com.itheima.mycollection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Demo1 {
    public static void main(String[] args) {
        //collection单列集合--->list和set集合(他们都是接口)
        Collection<String> collection = new ArrayList<>();//多态的语法
        //list集合(接口)--->ArrayList<>类和LinkedList<>类--->也可以说是collection<>集合的实现类
        //collection<>集合的方法有
        /*
        boolean add()
        boolean contains()
        boolean isEmply()
        boolean remove()
        void clear()


        */
        collection.add("龟田大郎");
        collection.add("龟田次郎");
        collection.add("龟田太郎");
        //size()方法
        int size = collection.size();
        System.out.println("长度" + size);
        //contains()方法和remove()方法
        if (collection.contains("龟田大郎")) {
             collection.remove("龟田大郎");

        }
        //
        collection.removeIf(s->collection.contains("太"));
        size = collection.size();
        System.out.println("长度" + size);
        //isEmpty()是否为空
        System.out.println("...............................");
        System.out.println(collection.isEmpty());
        System.out.println("...............................");
        //循环遍历
        Iterator<String> iterator = collection.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
        //clear()方法
        System.out.println("...............................");
        collection.clear();
        System.out.println(collection.isEmpty());


    }
}
